package com.seraph.zys.dao.impl;

import com.seraph.bi.suite.support.domain.pagination.PageBox;
import com.seraph.bi.suite.support.domain.pagination.PageObject;
import com.seraph.zys.dao.ScGlobalParmDAO;
import com.seraph.zys.dao.domain.ScGlobalParm;
import com.seraph.zys.dao.domain.ScGlobalParmExample;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

@Repository
public class ScGlobalParmDAOImpl extends SqlMapClientDaoSupport implements ScGlobalParmDAO {

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public ScGlobalParmDAOImpl() {
        super();
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public Integer insert(ScGlobalParm record) {
        Object newKey = getSqlMapClientTemplate().insert("sc_global_parm.abatorgenerated_insert", record);
        return (Integer) newKey;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public int updateByPrimaryKey(ScGlobalParm record) {
        int rows = getSqlMapClientTemplate().update("sc_global_parm.abatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public int updateByPrimaryKeySelective(ScGlobalParm record) {
        int rows = getSqlMapClientTemplate().update("sc_global_parm.abatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public List selectByExample(ScGlobalParmExample example, String orderByClause) {
        Map parms = getExampleParms(example);
        if (orderByClause != null) {
            parms.put("ABATOR_ORDER_BY_CLAUSE", orderByClause);
        }
        List list = getSqlMapClientTemplate().queryForList("sc_global_parm.abatorgenerated_selectByExample", parms);
        return list;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public List selectByExample(ScGlobalParmExample example) {
        return selectByExample(example, null);
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public ScGlobalParm selectByPrimaryKey(Integer id) {
        ScGlobalParm key = new ScGlobalParm();
        key.setId(id);
        ScGlobalParm record = (ScGlobalParm) getSqlMapClientTemplate().queryForObject("sc_global_parm.abatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public int deleteByExample(ScGlobalParmExample example) {
        int rows = getSqlMapClientTemplate().delete("sc_global_parm.abatorgenerated_deleteByExample", getExampleParms(example));
        return rows;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public int deleteByPrimaryKey(Integer id) {
        ScGlobalParm key = new ScGlobalParm();
        key.setId(id);
        int rows = getSqlMapClientTemplate().delete("sc_global_parm.abatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    private Map getIDExampleParms(ScGlobalParmExample example) {
        Map parms = new HashMap();
        switch (example.getId_Indicator()) {
        case ScGlobalParmExample.EXAMPLE_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_NULL", "Y");
            } else {
                parms.put("AND_ID_NULL", "Y");
            }
            break;
        case ScGlobalParmExample.EXAMPLE_NOT_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_NOT_NULL", "Y");
            } else {
                parms.put("AND_ID_NOT_NULL", "Y");
            }
            break;
        case ScGlobalParmExample.EXAMPLE_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_EQUALS", "Y");
            } else {
                parms.put("AND_ID_EQUALS", "Y");
            }
            parms.put("id", example.getId());
            break;
        case ScGlobalParmExample.EXAMPLE_NOT_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_NOT_EQUALS", "Y");
            } else {
                parms.put("AND_ID_NOT_EQUALS", "Y");
            }
            parms.put("id", example.getId());
            break;
        case ScGlobalParmExample.EXAMPLE_GREATER_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_GT", "Y");
            } else {
                parms.put("AND_ID_GT", "Y");
            }
            parms.put("id", example.getId());
            break;
        case ScGlobalParmExample.EXAMPLE_GREATER_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_GE", "Y");
            } else {
                parms.put("AND_ID_GE", "Y");
            }
            parms.put("id", example.getId());
            break;
        case ScGlobalParmExample.EXAMPLE_LESS_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_LT", "Y");
            } else {
                parms.put("AND_ID_LT", "Y");
            }
            parms.put("id", example.getId());
            break;
        case ScGlobalParmExample.EXAMPLE_LESS_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_LE", "Y");
            } else {
                parms.put("AND_ID_LE", "Y");
            }
            parms.put("id", example.getId());
            break;
        }
        return parms;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    private Map getPARM_CODEExampleParms(ScGlobalParmExample example) {
        Map parms = new HashMap();
        switch (example.getParmCode_Indicator()) {
        case ScGlobalParmExample.EXAMPLE_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_CODE_NULL", "Y");
            } else {
                parms.put("AND_PARM_CODE_NULL", "Y");
            }
            break;
        case ScGlobalParmExample.EXAMPLE_NOT_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_CODE_NOT_NULL", "Y");
            } else {
                parms.put("AND_PARM_CODE_NOT_NULL", "Y");
            }
            break;
        case ScGlobalParmExample.EXAMPLE_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_CODE_EQUALS", "Y");
            } else {
                parms.put("AND_PARM_CODE_EQUALS", "Y");
            }
            parms.put("parmCode", example.getParmCode());
            break;
        case ScGlobalParmExample.EXAMPLE_NOT_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_CODE_NOT_EQUALS", "Y");
            } else {
                parms.put("AND_PARM_CODE_NOT_EQUALS", "Y");
            }
            parms.put("parmCode", example.getParmCode());
            break;
        case ScGlobalParmExample.EXAMPLE_GREATER_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_CODE_GT", "Y");
            } else {
                parms.put("AND_PARM_CODE_GT", "Y");
            }
            parms.put("parmCode", example.getParmCode());
            break;
        case ScGlobalParmExample.EXAMPLE_GREATER_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_CODE_GE", "Y");
            } else {
                parms.put("AND_PARM_CODE_GE", "Y");
            }
            parms.put("parmCode", example.getParmCode());
            break;
        case ScGlobalParmExample.EXAMPLE_LESS_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_CODE_LT", "Y");
            } else {
                parms.put("AND_PARM_CODE_LT", "Y");
            }
            parms.put("parmCode", example.getParmCode());
            break;
        case ScGlobalParmExample.EXAMPLE_LESS_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_CODE_LE", "Y");
            } else {
                parms.put("AND_PARM_CODE_LE", "Y");
            }
            parms.put("parmCode", example.getParmCode());
            break;
        case ScGlobalParmExample.EXAMPLE_LIKE:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_CODE_LIKE", "Y");
            } else {
                parms.put("AND_PARM_CODE_LIKE", "Y");
            }
            parms.put("parmCode", example.getParmCode());
            break;
        }
        return parms;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    private Map getPARM_NAMEExampleParms(ScGlobalParmExample example) {
        Map parms = new HashMap();
        switch (example.getParmName_Indicator()) {
        case ScGlobalParmExample.EXAMPLE_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_NAME_NULL", "Y");
            } else {
                parms.put("AND_PARM_NAME_NULL", "Y");
            }
            break;
        case ScGlobalParmExample.EXAMPLE_NOT_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_NAME_NOT_NULL", "Y");
            } else {
                parms.put("AND_PARM_NAME_NOT_NULL", "Y");
            }
            break;
        case ScGlobalParmExample.EXAMPLE_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_NAME_EQUALS", "Y");
            } else {
                parms.put("AND_PARM_NAME_EQUALS", "Y");
            }
            parms.put("parmName", example.getParmName());
            break;
        case ScGlobalParmExample.EXAMPLE_NOT_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_NAME_NOT_EQUALS", "Y");
            } else {
                parms.put("AND_PARM_NAME_NOT_EQUALS", "Y");
            }
            parms.put("parmName", example.getParmName());
            break;
        case ScGlobalParmExample.EXAMPLE_GREATER_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_NAME_GT", "Y");
            } else {
                parms.put("AND_PARM_NAME_GT", "Y");
            }
            parms.put("parmName", example.getParmName());
            break;
        case ScGlobalParmExample.EXAMPLE_GREATER_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_NAME_GE", "Y");
            } else {
                parms.put("AND_PARM_NAME_GE", "Y");
            }
            parms.put("parmName", example.getParmName());
            break;
        case ScGlobalParmExample.EXAMPLE_LESS_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_NAME_LT", "Y");
            } else {
                parms.put("AND_PARM_NAME_LT", "Y");
            }
            parms.put("parmName", example.getParmName());
            break;
        case ScGlobalParmExample.EXAMPLE_LESS_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_NAME_LE", "Y");
            } else {
                parms.put("AND_PARM_NAME_LE", "Y");
            }
            parms.put("parmName", example.getParmName());
            break;
        case ScGlobalParmExample.EXAMPLE_LIKE:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_NAME_LIKE", "Y");
            } else {
                parms.put("AND_PARM_NAME_LIKE", "Y");
            }
            parms.put("parmName", example.getParmName());
            break;
        }
        return parms;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    private Map getPARM_VALUEExampleParms(ScGlobalParmExample example) {
        Map parms = new HashMap();
        switch (example.getParmValue_Indicator()) {
        case ScGlobalParmExample.EXAMPLE_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_VALUE_NULL", "Y");
            } else {
                parms.put("AND_PARM_VALUE_NULL", "Y");
            }
            break;
        case ScGlobalParmExample.EXAMPLE_NOT_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_VALUE_NOT_NULL", "Y");
            } else {
                parms.put("AND_PARM_VALUE_NOT_NULL", "Y");
            }
            break;
        case ScGlobalParmExample.EXAMPLE_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_VALUE_EQUALS", "Y");
            } else {
                parms.put("AND_PARM_VALUE_EQUALS", "Y");
            }
            parms.put("parmValue", example.getParmValue());
            break;
        case ScGlobalParmExample.EXAMPLE_NOT_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_VALUE_NOT_EQUALS", "Y");
            } else {
                parms.put("AND_PARM_VALUE_NOT_EQUALS", "Y");
            }
            parms.put("parmValue", example.getParmValue());
            break;
        case ScGlobalParmExample.EXAMPLE_GREATER_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_VALUE_GT", "Y");
            } else {
                parms.put("AND_PARM_VALUE_GT", "Y");
            }
            parms.put("parmValue", example.getParmValue());
            break;
        case ScGlobalParmExample.EXAMPLE_GREATER_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_VALUE_GE", "Y");
            } else {
                parms.put("AND_PARM_VALUE_GE", "Y");
            }
            parms.put("parmValue", example.getParmValue());
            break;
        case ScGlobalParmExample.EXAMPLE_LESS_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_VALUE_LT", "Y");
            } else {
                parms.put("AND_PARM_VALUE_LT", "Y");
            }
            parms.put("parmValue", example.getParmValue());
            break;
        case ScGlobalParmExample.EXAMPLE_LESS_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_VALUE_LE", "Y");
            } else {
                parms.put("AND_PARM_VALUE_LE", "Y");
            }
            parms.put("parmValue", example.getParmValue());
            break;
        case ScGlobalParmExample.EXAMPLE_LIKE:
            if (example.isCombineTypeOr()) {
                parms.put("OR_PARM_VALUE_LIKE", "Y");
            } else {
                parms.put("AND_PARM_VALUE_LIKE", "Y");
            }
            parms.put("parmValue", example.getParmValue());
            break;
        }
        return parms;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    private Map getDESCRIPTIONExampleParms(ScGlobalParmExample example) {
        Map parms = new HashMap();
        switch (example.getDescription_Indicator()) {
        case ScGlobalParmExample.EXAMPLE_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_NULL", "Y");
            } else {
                parms.put("AND_DESCRIPTION_NULL", "Y");
            }
            break;
        case ScGlobalParmExample.EXAMPLE_NOT_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_NOT_NULL", "Y");
            } else {
                parms.put("AND_DESCRIPTION_NOT_NULL", "Y");
            }
            break;
        case ScGlobalParmExample.EXAMPLE_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_EQUALS", "Y");
            } else {
                parms.put("AND_DESCRIPTION_EQUALS", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScGlobalParmExample.EXAMPLE_NOT_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_NOT_EQUALS", "Y");
            } else {
                parms.put("AND_DESCRIPTION_NOT_EQUALS", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScGlobalParmExample.EXAMPLE_GREATER_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_GT", "Y");
            } else {
                parms.put("AND_DESCRIPTION_GT", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScGlobalParmExample.EXAMPLE_GREATER_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_GE", "Y");
            } else {
                parms.put("AND_DESCRIPTION_GE", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScGlobalParmExample.EXAMPLE_LESS_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_LT", "Y");
            } else {
                parms.put("AND_DESCRIPTION_LT", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScGlobalParmExample.EXAMPLE_LESS_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_LE", "Y");
            } else {
                parms.put("AND_DESCRIPTION_LE", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScGlobalParmExample.EXAMPLE_LIKE:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_LIKE", "Y");
            } else {
                parms.put("AND_DESCRIPTION_LIKE", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        }
        return parms;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    private Map getExampleParms(ScGlobalParmExample example) {
        Map parms = new HashMap();
        parms.putAll(getIDExampleParms(example));
        parms.putAll(getPARM_CODEExampleParms(example));
        parms.putAll(getPARM_NAMEExampleParms(example));
        parms.putAll(getPARM_VALUEExampleParms(example));
        parms.putAll(getDESCRIPTIONExampleParms(example));
        return parms;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public int selectCountByExample(ScGlobalParmExample example) {
        Map parms = getExampleParms(example);
        int count = ((Integer)getSqlMapClientTemplate().queryForObject("sc_global_parm.abatorgenerated_selectCountByExample", parms)).intValue();
        return count;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public PageBox selectByExampleWithPaging(ScGlobalParmExample example, int pageSize, int pageNum, String orderByClause) {
        Map parms = getExampleParms(example);
        if (orderByClause != null) {
            parms.put("ABATOR_ORDER_BY_CLAUSE", orderByClause);
        }
        PageBox pageBox = new PageBox();
        PageObject pageObject = new PageObject();
        pageObject.setPageSize(pageSize);
        pageObject.setPageIndex(pageNum);
        int itemAmount = selectCountByExample(example);
        pageObject.setItemAmount(itemAmount);
        List pageList = null;
        if (pageObject.getBeginIndex() <= pageObject.getItemAmount()) {
            pageList = (getSqlMapClientTemplate().queryForList("sc_global_parm.abatorgenerated_selectByExample", parms, pageObject.getBeginIndex() - 1, pageSize));
        }
        pageBox.setPageObject(pageObject);
        pageBox.setPageList(pageList);
        return pageBox;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public PageBox selectByExampleWithPaging(ScGlobalParmExample example, int pageSize, int pageNum) {
        return selectByExampleWithPaging(example, pageSize, pageNum, null);
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_global_parm
     *
     * @abatorgenerated Wed Oct 19 14:49:28 CST 2011
     */
    public int updateByPrimaryKeyForCgs(ScGlobalParm record) {
        int rows = getSqlMapClientTemplate().update("sc_global_parm.abatorgenerated_updateByPrimaryKeyForCgs", record);
        return rows;
    }
}